<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增积分记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-integral-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">积分值：</label>
                <div class="col-sm-8">
                    <input name="integralCount" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">变更原因：</label>
                <div class="col-sm-8">
                    <textarea name="reason" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('integral_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="customerTreeId" name="customerId" type="hidden" th:value="null"/>
                        <input class="form-control" type="text" onclick="selectCustomerTree()" id="customerTreeName" readonly="true" th:value="null">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">子业务员：</label>
                <div class="col-sm-8">
                    <!--<input name="memberCid" class="form-control" type="text">-->
                    <div class="input-group">
                        <input id="memberTreeId" class="form-control" name="memberCid" type="hidden" th:value="null"/>
                        <input class="form-control" type="text" onclick="selectMemberTree()" id="memberTreeName" readonly="true" th:value="null">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
             <div class="form-group">
                <div class="col-sm-8">
               	    <input name="memberId" class="form-control" type="hidden" th:value="${member.id}">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "system/integral"
        $("#form-integral-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-integral-add').serialize());
            	window.parent.parent.$.treeTable.refresh();
            }
        }
        /*客户-新增-选择父部门树*/
        function selectCustomerTree() {
            var options = {
                title: '客户选择',
                width: "800",
                url: prefix + "/selectCustomerTree/" + $("#customerTreeId").val(),
                callBack: doSubmitCustomer
            };
            $.modal.openOptions(options);
        }

        function doSubmitCustomer(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#customerTreeId").val(body.find('#treeId').val());
            $("#customerTreeName").val(body.find('#treeName').val());
            layer.close(index);
        }

        /*业务员-新增-选择父部门树*/
        function selectMemberTree() {
            var options = {
                title: '子业务员选择',
                width: "800",
                url: prefix + "/selectMemberTree/" + $("#memberTreeId").val(),
                callBack: doSubmitMember
            };
            $.modal.openOptions(options);
        }

        function doSubmitMember(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#memberTreeId").val(body.find('#treeId').val());
            $("#memberTreeName").val(body.find('#treeName').val());
            layer.close(index);
        }


    </script>
</body>
</html>